<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      .reds{
        background-color: red;
      }
    </style>
</head>
<body>
    <div id="app">
        <ul>
          <!-- 对reds进行动态绑定 -->
          <!-- 需求一将索引为1的li添加上reds -->
          <!-- 需求二：用一个变量（属性）记录当前点击的位置 -->
          <li :class="{reds: index===redindex}" @click="redbutton(index)" v-for="(item, index) in movies" :key="index">
            {{item}}
          </li>
        </ul>
    </div>

    <script src="./lib/Vue.js"></script>
    <script>
        const app = Vue.createApp({
            data() {
                return{
                  movies:["星际穿越", "阿凡达", "大话西游", "黑客帝国"],
                  redindex:0
                }
            },
            methods:{
              redbutton(index){
                this.redindex = index
              }
            }
        })
        app.mount("#app")
    </script>
</body>
</html>